home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5542 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  6.7 KB

  1. Path: cs.utexas.edu!not-for-mail
  2. From: wilson@cs.utexas.edu (Paul Wilson)
  3. Newsgroups: comp.lang.lisp,comp.lang.c++,comp.lang.c,comp.lang.misc,comp.theory
  4. Subject: allocator studies (was Re: GC & traditional allocators & textbooks)
  5. Date: 5 Feb 1996 09:56:51 -0600
  6. Organization: CS Dept, University of Texas at Austin
  7. Distribution: inet
  8. Message-ID: <4f59c3$7il@jive.cs.utexas.edu>
  9. References: <rvillDL4v3n.I8r@netcom.com> <823365355snz@wildcard.demon.co.uk> <4f2ila$6p8@jive.cs.utexas.edu> <823455623snz@wildcard.demon.co.uk>
  10. NNTP-Posting-Host: jive.cs.utexas.edu
  11.  
  12. In article <823455623snz@wildcard.demon.co.uk>,
  13. Cyber Surfer  <cyber_surfer@wildcard.demon.co.uk> wrote:
  14. >In article <4f2ila$6p8@jive.cs.utexas.edu>
  15. >           wilson@cs.utexas.edu "Paul Wilson" writes:
  16. >
  17. >> The history of allocator
  18. >> research has been a big mess---the literature is a bit of a disaster
  19. >> area---and the textbooks reflect this.  The analyses in the books are 
  20. >> shallow and largely wrong.  (This is less attributable to the textbooks
  21. >> authors than the weak discussions of GC.  It's not their fault that they
  22. >> can't summarize the gist of the literature and get it right, because
  23. >> the literature in general is disorganized, inconsistent, and often wrong.)
  24. >
  25. >I won't argue with that! ;-) I'd love to see a good summary.
  26.  
  27. Well, very briefly:
  28.  
  29.    1. Traditional allocator research has largely missed the point, because
  30.       the true causes of fragmentation haven't been studied much.  Most
  31.       studies (a recent exception being Zorn, Grunwald, and Barrett's
  32.       work at the U. of Colorado at Boulder, and Phong Vo's latest paper
  33.       from Bell Labs) have used synthetic traces whose realism has never
  34.       been validated, rather than real program behavior.
  35.  
  36.    2. The standard synthetic traces of "program" behavior are unrealistic,
  37.       because they're based on pseudo-random sequences, even if the
  38.       object size and lifetime distributions are realistic.  For good
  39.       allocator policies, this causes an unrealistically high degree
  40.       of fragmentation, because you're shooting holes in the heap at
  41.       random.  For some programs and some allocators, though, you get
  42.       unrealistically low fragmentation.  In general, the random trace
  43.       methodology makes most allocators' performance look pretty similar,
  44.       when in fact the regularities in real traces make some allocators
  45.       work *much* better than others.
  46.  
  47.    3. People have often focused on the speed of allocator mechanisms,
  48.       at the expense of studying the effects of policy in a realistic
  49.       context.  As it turns out, some of the best policies are amenable
  50.       to fast implementations if you just think about it as a normal
  51.       data-structures-and-algorithms problem.  The best policies have
  52.       often been neglected because people confused policy and mechanism,
  53.       and the best-known mechanisms were slow.
  54.  
  55.    4. People have usually failed to separate out "true" fragmentation
  56.       costs---due to the allocator's placement policy and its interactions
  57.       with real program behavior---from simple overheads of simplistic
  58.       mechanisms.  Straightforward tweaks can reduce these costs easily.
  59.      
  60.    5. The best-known policies (best fit and address-ordered first fit)
  61.       work better than anyone ever knew, while some policies (Knuth's
  62.       "Modified First Fit" or "Next Fit") work worse than anyone ever
  63.       knew, for some programs.  This is because randomized traces tend
  64.       probabilistically to ensure that certain important realistic
  65.       program behaviors will never happen in traditional experiments.
  66.  
  67.    6. None of the analytical results in the literature (beginning with
  68.       Knuth's "fifty percent rule") are valid.  They're generally based
  69.       on two or three assumptions that are all systematically false for
  70.       most real programs.  (Random allocation order, steady-state behavior,
  71.       and independence of sizes and lifetimes.  To make mathematical
  72.       analyses tractable, people have sometimes made stronger and even
  73.       more systematically false assumptions, like exponentially-distributed
  74.       random lifetimes.)
  75.  
  76.    7. Because of these problems, most allocator research over the last
  77.       35 years has been a big waste of time, and we still don't know
  78.       much more than we knew in 1968, and almost nothing we didn't
  79.       know in the mid-70's.
  80.  
  81. > [...]
  82. >> "Modified First Fit" with the roving pointer is the clearest example.  It
  83. >> was a bad idea, and it was quickly shown to be bad, but some other textbook
  84. >> writers keep mindlessly cribbing from Knuth, and even some implementors still
  85. >> use it.
  86. >
  87. >Is it really worse than Best Fit? I've wondered about that ever
  88. >since first read that book. You seem like a good person to ask. ;)
  89.  
  90. Yes, it is significantly worse, and some versions are often far worse, even
  91. pathological.  If you keep the free list in address order, it's just worse.
  92. If you keep the free list in LIFO order, it can be pathological.  (LIFO
  93. order is attractive because it's cheaper than address order, and if all
  94. other things were equal, it would improve locality.)  For some programs,
  95. it systematically takes little bites out of big free blocks, making those
  96. blocks unusable for allocation requests of the same big size in the future.
  97. Many traditional experiments have masked this effect by using smooth
  98. distributions of object sizes, so that odd-sized blocks are less of a
  99. problem.
  100.  
  101. (Given random sizes, you're likely to have a request that's a good fit
  102. for the block size pretty soon, even after taking a bite out of it.  For
  103. real traces, you're likely *not* to get any requests for
  104. comparable-but-smaller sizes anytime soon.  And the randomization of
  105. order tends to eliminate the potential pathological interactions due
  106. to particular sequence behavior.  You eliminate the extreme cases.)
  107.  
  108. >> Obligatory positive comment:  the best textbook discussion of allocators
  109. >> that I know of is Tim Standish's in _Data_Structure_Techniques_.  He doesn't
  110. >> recognize the near-universal methodological problems with allocator studies,
  111. >> but he's unique in recognizing the basic data structure and algorithm issues
  112. >> in implementing allocators.
  113. >
  114. >I'll see if I can find that book. Thanks.
  115. >
  116. >> [Our] site [http://www.cs.utexas.edu/users/oops/] also has our big survey 
  117. >> on memory allocators from IWMM '95, which I hope will influence future
  118. >> textbooks.  It talks about empirical methodology as well as giving a
  119. >> fairly exhaustive treatment of implementation techniques.
  120.  
  121. -- 
  122. | Paul R. Wilson, Comp. Sci. Dept., U of Texas @ Austin (wilson@cs.utexas.edu)
  123. | Papers on memory allocators, garbage collection, memory hierarchies,
  124. | persistence and  Scheme interpreters and compilers available via ftp from 
  125. | ftp.cs.utexas.edu, in pub/garbage (or http://www.cs.utexas.edu/users/wilson/)      
  126.